package com.vhall.component.entity.data.enums;

import lombok.Getter;

import java.util.Objects;

/**
 * SortTypeEnum-
 *
 * @author xing.wang
 * @date 2023/11/21
 */
@Getter
public enum SortTypeEnum {
    ASC_SORT(3,"正序")
    ,DESC_SORT(4,"倒序")
    ;
    private final Integer value;
    private final String name;

    SortTypeEnum(Integer value,String name) {
        this.name = name;
        this.value = value;
    }

    /**
     * 获取指定内容对应的排序规则
     * @param value 对应的枚举值
     * @param defaultEnum 默认的枚举
     * @return
     */
    public static SortTypeEnum getSortTypeEnum(Integer value,SortTypeEnum defaultEnum){
        for (SortTypeEnum sortTypeEnum : SortTypeEnum.values()) {
            if(Objects.equals(sortTypeEnum.getValue(),value)){
                return sortTypeEnum;
            }
        }
        return defaultEnum;
    }
}
